<template>
  <div id="comment_main">
    <div id="comment">
      <div class="shop_list">
        <span>全部评论数量</span
        ><span class="text_1">{{ this.totalCommentCount }}</span
        ><span>个,</span><span>提问</span
        ><span class="text_2">{{ this.totalQuesCount }}</span
        ><span>个,</span> <span>回答</span
        ><span class="text_2">{{ this.totalAnsCount }}</span
        ><span>个</span>
        <div class="com_bq">
          <el-tabs v-model="activeName">
            <el-tab-pane label="评论" name="first">
              <div class="com_pl">
                <div class="com_cx">
                  <el-row :gutter="20">
                    <el-col :span="6">
                      <div class="grid-content bg-purple">
                        <span>雪场名称</span>
                        <el-input
                          style="width: 60px"
                          v-model="item_serach.scenicName"
                        ></el-input>
                      </div>
                    </el-col>
                    <el-col :span="6">
                      <div class="grid-content bg-purple">
                        <el-input
                          placeholder="请输入关键字"
                          style="width: 60px"
                        ></el-input>
                      </div>
                    </el-col>
                  </el-row>
                  <el-button class="com_chax" type="primary" @click="com_serach"
                    >查询</el-button
                  >
                </div>
                <div class="com_hs"></div>
                <div class="com_faf">
                  <ul class="_comment_list">
                    <li :key="index" v-for="(item, index) in comlist">
                      <div class="com_card">
                        <div class="com_bx">
                          <el-checkbox v-model="checked">{{
                            item.fullname
                          }}</el-checkbox>
                        </div>
                        <div class="com_sb">
                          <el-link type="danger" @click="delete_com(item)"
                            >删除</el-link
                          >
                          <el-link type="primary">标星</el-link>
                        </div>
                        <div class="com_time">
                          <span>{{ item.created_at }}</span>
                        </div>
                        <div class="com_brief">
                          <span>{{ item.content }}</span>
                        </div>
                        <ul class="com_image">
                          <li :key="index" v-for="(item, index) in comlist">
                            <img :src="item.img" alt="" />
                          </li>
                        </ul>
                      </div>
                    </li>
                  </ul>
                </div>
                <div class="block">
                  <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page.sync="currentPage1"
                    :page-size="20"
                    background
                    layout="total, prev, pager, next"
                    :total="6"
                  >
                  </el-pagination>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="提问" name="second">
              <div class="com_quiz">
                <!-- <button @click="getquestionsList">获取提问数据</button> -->
                <div class="com_pl">
                  <div class="com_cx">
                    <el-row :gutter="20">
                      <el-col :span="6">
                        <div class="grid-content bg-purple">
                          <span>雪场名称</span>
                          <el-input style="width: 60px"></el-input>
                        </div>
                      </el-col>
                      <el-col :span="6">
                        <div class="grid-content bg-purple">
                          <el-input
                            placeholder="请输入关键字"
                            style="width: 60px"
                          ></el-input>
                        </div>
                      </el-col>
                    </el-row>
                    <el-button class="com_chax" type="primary">查询</el-button>
                  </div>
                  <div class="com_hs"></div>
                  <div class="com_faf">
                    <ul class="tw_comt">
                      <li v-for="(item, index) in quizlist" :key="index">
                        <div class="card_comt" ref="card_comt">
                          <div class="del_com">
                            <el-link type="danger">删除</el-link>
                          </div>
                          <div class="com_title">
                            <span>01</span><span>{{ item.fullname }}</span>
                          </div>
                          <div>
                            <span>{{ item.created_at }}</span>
                          </div>
                          <div class="com_quiz">
                            <span>提问：</span><span>{{ item.content }}</span>
                          </div>
                          <el-collapse accordion>
                            <el-collapse-item>
                              <template slot="title"> 回答 </template>
                              <div>{{ item.content }}</div>
                            </el-collapse-item>
                          </el-collapse>
                        </div>
                      </li>
                    </ul>
                  </div>
                </div>
              </div>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
      <!-- <button @click="getcommentsList">获取评论列表数据</button> -->
    </div>
  </div>
</template>
<script>
import {
  getcommentsList,
  getquestionsList,
  getdeleteComment,
} from "../request/index";
export default {
  data() {
    return {
      totalCommentCount: "",
      activeName: "first",
      checked: true,
      comlist: [],
      scenicid: "",
      quizlist: [],
      totalQuesCount: "",
      item_serach: {
        scenicName: "",
      },
      totalAnsCount: "",
      currentPage1: null,
    };
  },

  methods: {
    //评论搜索
    com_serach() {
      getcommentsList(this.item_serach).then((res) => {
        console.log(res);
        this.comlist = res.list;
      });
    },
    getcommentsList() {
      this.scenicid = this.$route.query;
      console.log(this.scenicid.id);
      console.log(111);
      getcommentsList({ scenicid: this.scenicid.id }).then((res) => {
        console.log(res);
        this.comlist = res.list;
        this.totalCommentCount = res.totalCommentCount;
        this.totalQuesCount = res.totalQuesCount;
        this.totalAnsCount = res.totalAnsCount;
      });
    },
    //删除
    delete_com(item) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let data = {
            id: item.id,
            type: 1,
          };
          getdeleteComment(data).then((res) => {
            console.log(res);
            this.$message({
              message: "删除成功",
              type: "success",
            });
            this.getcommentsList();
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    zhankai() {
      console.log(111);
      // this.$refs.card_comt.style.height = "300px";
      if (this.$refs.card_comt.style.height != "300px") {
        this.$refs.card_comt.style.height == "300px";
      } else {
      }
    },
    getquestionsList() {
      console.log(111);
      getquestionsList().then((res) => {
        console.log(res);
        console.log(res.list);
        this.quizlist = res.list;
      });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    //翻页
    handleCurrentChange(val) {
      getcommentsList({ page: val }).then((res) => {
        console.log(res);
        this.comlist = res.list;
      });
    },
  },
  mounted() {
    this.getcommentsList(), this.getquestionsList();
  },
};
</script>
<style>
.block {
  position: absolute;
  bottom: 30px;
  left: 530px;
}
.com_image > li > img {
  width: 100%;
  height: 100%;
}
.com_image > li {
  width: 50px;
  height: 50px;
  background-color: #ccc;
  margin-top: 120px;
  float: left;
  margin-left: 15px;
}

.del_com {
  position: absolute;
  right: 30px;
  /* top: 10px; */
}

.com_quiz {
  font-weight: 700;
}

.com_title {
  font-size: 15px;
  font-weight: 700;
}

.tw_comt > li {
  float: left;
  margin-left: 15px;
  margin-top: 15px;
}

.card_comt {
  width: 400px;
  height: 200px;
  background-color: #fff;
  /* overflow:hidden; */
  border-radius: 5px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
  position: relative;
}

._comment_list > li {
  float: left;
  margin-left: 30px;
  margin-top: 20px;
}

#comment_main {
  width: 100%;
  height: 800px;
  /* background-color: skyblue; */
}

.com_brief {
  position: absolute;
  top: 71px;
  left: 10px;
}

.com_time > span {
  font-size: 12px;
}

.com_time {
  position: absolute;
  top: 30px;
  left: 12px;
}

.com_sb {
  position: absolute;
  right: 10px;
  top: 5px;
}

.el-link--inner {
  margin-right: 15px;
}

.com_bx {
  position: absolute;
  left: 10px;
  top: 5px;
}

.com_card {
  width: 478px;
  height: 213px;
  background-color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
}

.com_faf {
  width: 100%;
  height: 550px;
  background-color: #f3f5fa;
  /* background-color: skyblue; */
}

.cell {
  text-align: center;
}

.com_hs {
  width: 100%;
  height: 20px;
  background-color: #f3f5fa;
}

.com_chax {
  position: absolute;
  right: 0;
  top: 35px;
  width: 100px;

  right: 30px;
}

.com_cx {
  width: 100%;
  height: 100px;
  border-radius: 8px;
  /* border-radius: 50%; */
}

#comment {
  width: 100%;
  height: 145px;
  background-color: #fff;
  position: relative;
  top: 20px;
  border-radius: 10px;
}

.com_bq {
  position: absolute;
  top: 90px;
  left: -19px;
  width: 103%;
  height: 690px;
}

.com_pl {
  width: 100%;
  height: 650px;
  background-color: #fff;
}

.el-row {
  margin-bottom: 20px;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.men_fe {
  width: 100%;
  height: 25px;
  background-color: #f3f5fa;
}

.member_footer {
  width: 100%;
  /* background-color: red; */
  position: relative;
  top: 15px;
  border-radius: 10px;
  height: 100%;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
  margin-top: 30px;
}

.but_cx {
  position: absolute;
  right: 15px;
  top: 30px;
}

input.el-input__inner {
  width: 208px;
}

.el-input__inner {
  width: 213px;
}

.element.style {
  padding-left: 10px;
  margin-top: 27px;
  padding-right: 10px;
}

element.style {
  padding-left: 10px;
  padding-right: 10px;
  margin-top: 27px;
}

element.style {
  padding-left: 10px;
  margin-top: 27px;
  padding-right: 10px;
}

element.style {
  padding-left: 10px;
  padding-right: 10px;
  margin-top: 27px;
}

.el-col-6 {
  width: 18%;
}

.grid-content bg-purple {
  width: 100px;
}

.el-row {
  margin-bottom: 20px;
  width: 95%;
}

.el-col {
  border-radius: 4px;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.el-table--border th.el-table__cell,
.el-table__fixed-right-patch {
  border-bottom: 1px solid #ebeef5;
  background-color: #f2f6fc;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.s_hy {
  vertical-align: -5px;
}

.ipt_hy {
  display: inline-block;
  position: absolute;
  width: 100px !important;
}

.el-input__inner {
  width: 207px;
}

.bgc_3a {
  width: 100%;
  height: 25px;
  background-color: #f3f5fa;
}

.reg {
  background-color: #fff;
}

.btn_reg {
  width: 250px;
  position: absolute;
  bottom: 25px;
  right: 200px;
  background-color: #2a78ff;
}

.reg > ul > li {
  margin-top: 45px;
  margin-left: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  list-style-type: circle;
}

.el-menu-item is-active {
  background-color: red;
}

.el-input__inner {
  width: 400px;
}

#pane-first {
  height: 100%;
}

.privatekey {
  position: relative;
  height: 900px;
}

.zf {
  /* background-color: #fff; */
  margin-top: 30px;
  height: 740px;
}

.jiekou {
  margin-left: 50px;
}

.el-tabs__item {
  font-size: 16px;
  font-weight: 700;
}

.el-tabs__item {
  padding: 0 48px;
}

#tab-first {
  padding-left: 20px;
}

.reg {
  width: 600px;
  height: 350px;
  border: 1px solid #000;
  position: relative;
  top: 150px;
  bottom: 0;
  right: 0;
  left: 0;
  margin: auto;
  border: 1px solid #dcdfe6;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  border-radius: 5px;
}

.block {
  position: absolute;
  bottom: -9px;
  left: 530px;
}

.snow_footer {
  width: 100%;
  background-color: #fff;
  position: relative;
  top: 50px;
  border-radius: 10px;
  height: 650px;
}

.query_2 {
  position: absolute;
  left: 300px;
  top: 90px;
}

.snow_btn {
  position: absolute;
  right: -1300px;
  top: 0px;
}

.nav_hedr {
  width: 100%;
  height: 145px;
  background-color: #fff;
  position: relative;
  top: 20px;
  border-radius: 10px;
}

.snow_list {
  width: 98%;
  height: 40px;
  background-color: #ebf4ff;
  position: absolute;
  left: 25px;
  top: 10px;
  border-radius: 5px;
}

.shop_list {
  width: 98%;
  height: 40px;
  background-color: #ebf4ff;
  position: absolute;
  left: 1%;
  top: 10px;
  border-radius: 5px;
  line-height: 40px;
}

.snow_list {
  line-height: 40px;
}

.text_1 {
  color: #3d85ff;
  font-size: 20px;
}

.text_2 {
  color: #3d85ff;
  font-size: 20px;
}

.snow_name {
  display: inline-block;
  width: 250px;
  height: 25px;
}

.query {
  position: absolute;
  left: 25px;
  top: 90px;
}

.el-input__inner {
  height: 35px;
  margin-left: 5px;
}

.zf {
  /* background-color: #fff; */
  margin-top: 30px;
  height: 740px;
}

.jiekou {
  margin-left: 50px;
}

.el-tabs__item {
  font-size: 16px;
  font-weight: 700;
}

.el-tabs__item {
  padding: 0 48px;
}

#tab-first {
  padding-left: 20px;
}

.el-tabs el-tabs--top {
  position: absolute;
  top: -25px;
  background-color: red;
}

.el-container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  -ms-flex-preferred-size: auto;
  flex-basis: auto;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  min-width: 0;
  height: 100%;
}

element.style {
  position: absolute;
  top: 15px;
  margin-left: -27px;
  width: 1648px;
}

.men_jy {
  width: 100%;
  height: 700px;
  background-color: #fff;
}

.men_id {
  width: 100%;
  height: 700px;
  background-color: #fff;
  position: absolute;
  z-index: 100;
}

.nav_header {
  width: 100%;
  height: 145px;
  background-color: #fff;
  position: relative;
  top: 20px;
  border-radius: 10px;
}

.mem_tag {
  position: absolute;
  top: 90px;
  width: 100%;
}

#member {
  width: 100%;
  height: 100%;
  /* background-color: red; */
}

.shoplist {
  width: 100%;
}

.el-tabs__nav-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  display: none;
  bottom: 0;
  width: 100%;
  height: 2px;
  background-color: #e4e7ed;
  z-index: 1;
}
</style>